package cn.edu.mju.dilidili.auth.controller;

import cn.edu.mju.dilidili.auth.serviceFeign.UserServiceFeign;
import cn.edu.mju.dilidili.common.exception.VerifyException;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 作用描述
 *
 * @author linzsh
 * @date 2022/9/24 21:04
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/auth")
public class AuthController {
    final UserServiceFeign userServiceFeign;
    final CaptchaController controller;

    // todo 公司连不上数据库, 回去后调通接口
    @PostMapping("/login")
    String login(String username, String password, String captcha) {
        if (!captcha.equals(controller.getCaptcha().getData())) {
            throw new VerifyException();
        }
        return userServiceFeign.login(username, password);
    }
}
